//==========================================================================
// Copyright (c) 2000-2008,  Elastos, Inc.  All Rights Reserved.
//==========================================================================
#if _MSC_VER > 1000
#pragma once
#endif

#if !defined(__CKTFSFILE_H__)
#define __CKTFSFILE_H__

#define _NO_CKTFSFILE_CLASSOBJECT_
#include "_CKtfsFile.h"
#include <fatfile.h>

class CKtfsFile : public _CKtfsFile
{
public:
    CARAPI Read(
        /* [in] */ Int32  offset,
        /* [in] */ Int32  toRead,
        /* [out] */ MemoryBuf * pBuf);

    CARAPI Write(
        /* [in] */ Int32  offset,
        /* [in] */ const MemoryBuf & ezbBuf,
        /* [out] */ Int32  * pWrite);

    CARAPI GetSize(
        /* [out] */ Int32  * pSize);

    CARAPI SetSize(
        /* [in] */ Int32  size);

    CARAPI GetOptimalBlockSize(
        /* [out] */ Int32  * pSize);

    CARAPI Sync();

    CARAPI GetType(
        /* [out] */ FileType * pType);

    CARAPI GetAccessTime(
        /* [out] */ Int32 * pTime);

    CARAPI SetAccessTime(
        /* [in] */ Int32 time);

    CARAPI GetModificationTime(
        /* [out] */ Int32 * pTime);

    CARAPI SetModificationTime(
        /* [in] */ Int32 time);

    CARAPI GetCreateTime(
        /* [out] */ Int32 * pTime);

    CARAPI CheckAccessMode(
        /* [in] */ FileAccessMode mode);

    CARAPI GetAccessMode(
        /* [out] */ FileAccessMode * pMode);

    CARAPI SetAccessMode(
        /* [in] */ FileAccessMode mode);

    CARAPI GetShareMode(
        /* [out] */ FileShareMode *pMode);

    CARAPI SetShareMode(
        /* [in] */ FileShareMode mode);

    ~CKtfsFile();

    CKtfsFile(class CFatFile *pFatFile): m_pCFatFile(pFatFile)
    {
        m_pCFatFile->AddRef();
    }

    CARAPI AddFileMonitor(
        /* [out] */ IEvent **pEvent);

    CARAPI RemoveFileMonitor(
        /* [in] */ IEvent *pEvent);

private:
    CKtfsFile() { }

    inline void Lock();
    inline void Unlock();
    class CFatFile *m_pCFatFile;
};

#endif //!(__CBASICFILE_H__)
